//************************************************************
//    > File Name: count-and-say.cpp
//    > Author: davis
//    > Mail:  
//    > Created Time: 2017年03月22日  9:56:34
//***********************************************************
//lintcode #420
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<sstream>
using namespace std;

string getNext(const string& seq){
	stringstream next_seq;
	for(int i=0;i<seq.length();++i){
		int cnt=1;
		while(i<seq.length()-1 && seq[i]==seq[i+1])
			++cnt,++i;
		next_seq << cnt << seq[i];
	}
	return next_seq.str();
}

string countAndSay(int n){
	string seq{"1"};
	for(int i=0;i<n-1;++i)
		seq=getNext(seq);
	return seq;
}
int main(){
	int n;
	cout<<"enter a number:";
	cin>>n;
	string s=countAndSay(n);
	cout<<s<<endl;
		
}
